package com.ghsc.ghxc.jsb.ui.live.view

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.alivc.auicommon.core.base.MessageModel
import com.cn.appcore.event.RxBus
import com.cn.appcore.event.RxBusBean
import com.cn.appcore.ext.setSingleClickListener
import com.cn.appcore.ext.showToast
import com.cn.appcore.http.constant.HttpConstant
import com.cn.appcore.utils.GlideUtil
import com.cn.appcore.utils.GsonUtil
import com.cn.appcore.utils.Preference
import com.flyco.roundview.RoundTextView
import com.lxj.xpopup.core.BottomPopupView
import com.ghsc.ghxc.jsb.R
import com.ghsc.ghxc.jsb.api.ApiMarket
import com.ghsc.ghxc.jsb.config.UserManager
import com.ghsc.ghxc.jsb.ext.http.request
import de.hdodenhof.circleimageview.CircleImageView

/**
 * 项目：JingShortVideo
 * 包名：com.bbl.jyShortVideo.ui.video.live.view
 * 类名：LiveSharePopupView
 * 创建时间：2022/12/21 17:00
 * 创建人 @author： xiaolin
 * 描述 ：Todo...直播间点击某个人的信息
 */
class LiveUserInfoPopupView(context: AppCompatActivity,tuid:String,liveId:String,anchorId:String) : BottomPopupView(context) {

    override fun getImplLayoutId() = R.layout.live_user_info
    private val mContext = context
    private val tuid=tuid
    private val liveId=liveId
    private  val anchorId=anchorId

    private var userId: String by Preference(HttpConstant.USER_ID, "")
    override fun onCreate() {
        super.onCreate()
        var ivHead=findViewById<CircleImageView>(R.id.iv_head)
        var tvBtnFollow=findViewById<RoundTextView>(R.id.tvBtnFollow)
        var tvName=findViewById<TextView>(R.id.tvName)
        var tvFollow=findViewById<TextView>(R.id.tvFollow)
        var tvFans=findViewById<TextView>(R.id.tvFans)

        if(tuid==userId){
            tvBtnFollow.visibility=View.INVISIBLE
        }else {
            tvBtnFollow.visibility=View.VISIBLE
        }
        val map: HashMap<String, Any> = HashMap()
        map["userid"] = tuid
        val json=  GsonUtil.mapToJsonStrObjEncryption(map)
        mContext.request({ ApiMarket.service.onGetOppositeInfoData(json!!) }, {
            GlideUtil.ImageHeadLoad(mContext,it.data.headimg,ivHead)
            tvName.text=it.data.nickname
            tvFollow.text=it.data.follows.toString()
            tvFans.text=it.data.fans.toString()
        })
        tvBtnFollow.setSingleClickListener {
//            val map: HashMap<String, Any> = java.util.HashMap()
//            map["tuid"] = tuid
//            val json=  GsonUtil.mapToJsonStrObjEncryption(map)
//            mContext.request({ ApiMarket.service.onUserFollowData(json!!) }, {
//                if (it.data.flag==1){
//                    tvBtnFollow.text="取消关注"
//                }else{
//                    tvBtnFollow.text="关 注"
//                }
//            })
            showToast("暂未开放,敬请期待")
        }
        findViewById<TextView>(R.id.tvBtnCancel).setOnClickListener {
            dismiss()
        }
    }

    override fun getMaxWidth() = 0
}